﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MiniErp.Core.Filters;
using MiniErp.Entity.DataStreams.DTOs;
using MiniErp.Entity.DataStreams.DTOs.Rights;
using MiniErp.Service.BusinessService.IService.Rights;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

/// <summary>
/// 权限管理系统
/// </summary>
namespace MiniErp.Core.Controllers.RightsManagement
{
    /// <summary>
    /// 权限控制器
    /// </summary>
    [Route("Rights")]
    public class RightsController : ApiControllers
    {
        private readonly IRightsService _rightsService;
        public RightsController(IRightsService rightsService)
        {
            _rightsService = rightsService;
        }
        /// <summary>
        /// 查询所有岗位系统权限信息 //分页
        /// </summary>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        [HttpGet]
        [Route("GetAllRightsAsync")]
        public Task<List<RightsDTO>> GetAllRightsAsync(int page, int num)
        {
            return _rightsService.GetAllRightsAsync(page, num);
        }

        /// <summary>
        /// 指定岗位编号查询岗位系统权限信息 //分页
        /// </summary>
        /// <param name="jobsid">岗位编号</param>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        [HttpGet]
        [Route("GetRightsByJobsIdAsync")]
        public Task<List<RightsDTO>> GetRightsByJobsIdAsync(int jobsid, int page, int num)
        {
            return _rightsService.GetRightsByJobsIdAsync(jobsid, page, num);
        }
        /// <summary>
        ///  指定系统编号查询岗位系统权限信息 //分页
        /// </summary>
        /// <param name="systemsid">系统编号</param>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        [HttpGet]
        [Route("GetRightsBySystemsIdAsync")]
        public Task<List<RightsDTO>> GetRightsBySystemsIdAsync(int systemsid, int page, int num)
        {
            return _rightsService.GetRightsBySystemsIdAsync(systemsid, page, num);
        }
        /// <summary>
        /// 修改岗位系统权限信息
        /// </summary>
        /// <param name="rightsDTO">修改岗位系统权限DTO</param>
        [HttpPost]
        [Route("UpdateRightsAsync")]
        public Task<bool> UpdateRightsAsync(UpdateRightsDto rightsDTO)
        {
            return _rightsService.UpdateRightsAsync(rightsDTO);
        }
        /// <summary>
        /// 新增岗位系统权限信息
        /// </summary>
        /// <param name="rightsDTO">新增岗位系统权限DTO</param>
        [HttpPost]
        [Route("AddRightsAsync")]
        public Task<bool> AddRightsAsync(AddRightsDTO rightsDTO)
        {
            return _rightsService.AddRightsAsync(rightsDTO);

        }
        /// <summary>
        /// 删除岗位系统权限信息
        /// </summary>
        /// <param name="JobsSystemsRightsId">岗位系统权限编号</param>
        [HttpDelete]
        [Route("DeleteRightsAsync")]
        public Task<bool> DeleteRightsAsync(int JobsSystemsRightsId)
        {
            return _rightsService.DeleteRightsAsync(JobsSystemsRightsId);
        }
    }
}
